import init from './initialization';
import createStore from './datastore';

(async () => {
  const initResources = await init();
  const store = createStore(initResources);
  // store.actions.startSimulation();
})().catch(e => {
  const h = document.createElement('H1');
  h.innerText = '500 Server Error';
  document.body.appendChild(h);
  console.error(e);
});

// import * as THREE from "three";
// import { BufferAttribute, TextureLoader } from "three";
// import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
// import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
// var w = window.innerWidth, h = window.innerHeight
// var camera, scene, renderer, mesh
// const CUBE_DIR = 'static/sky/';
// const CUBE_FILES = [
//   'TropicalSunnyDayLeft2048.png',
//   'TropicalSunnyDayRight2048.png',
//   'TropicalSunnyDayUp2048.png',
//   'TropicalSunnyDayDown2048.png',
//   'TropicalSunnyDayFront2048.png',
//   'TropicalSunnyDayBack2048.png',
// ];

// function init() {
//   scene = new THREE.Scene()
//   // scene.background = new THREE.CubeTextureLoader().setPath(CUBE_DIR).load(CUBE_FILES);

//   camera = new THREE.PerspectiveCamera(45, w / h, 1, 1000)
//   camera.position.set(0, 300, 0)
//   camera.up.y = 1
//   // camera.lookAt(scene.position)

//   renderer = new THREE.WebGLRenderer()
//   // renderer.setClearColor(0x3f5e6a)
//   renderer.shadowMap.enabled = true
//   renderer.shadowMap.type = THREE.PCFSoftShadowMap
//   renderer.setSize(w, h)
//   renderer.setClearColor(0x808e8d)
//   document.body.appendChild(renderer.domElement)
//   createGeometry()
//   createLight()
// }
// var texture2
// function createGeometry() {

//   new OBJLoader().load(
//     '/static/arrows/LeftArrow.obj',
//     (obj) => {
//       console.log('=====',obj);
//       obj.scale.set(20,20,20)
//       scene.add(obj)
//       animate()
//     }
//   )

// }
// var light2
// function createLight() {
//   var light1 = new THREE.AmbientLight(0xffffff, 0.1)
//   scene.add(light1)

//   light2 = new THREE.DirectionalLight(0xffffff, 0.8)
//   light2.position.set(0, 400, 0)

//   scene.add(light2)

//   const light3 = new THREE.DirectionalLight(0xffffff, 0.8)
//   light2.position.set(0, -400, 0)

//   scene.add(light3)


// }
// THREE.MeshPhongMaterial
// function animate() {
//   requestAnimationFrame(animate)
//   renderer.render(scene, camera)

// }

// init()
// animate()
// // /** --------------------鼠标控件对象--------------------- */
// let controls = new OrbitControls(camera, renderer.domElement); //创建控件对象
// controls.addEventListener("change", animate); //监听鼠标、键盘事件
